package com.ruoyi.web.controller.billSettings;


import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BillingRuleOperationLogs;
import com.ruoyi.system.service.IBillingRuleOperationLogsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 计费规则操作记录Controller
 *
 * @author ruoyi
 * @date 2025-05-19
 */
@Api(tags="计费规则操作记录")
@RestController
@RequestMapping("/system/billingRuleOperationLogs")
public class BillingRuleOperationLogsController extends BaseController
{
    @Autowired
    private IBillingRuleOperationLogsService billingRuleOperationLogsService;

    /**
     * 查询计费规则操作记录列表
     */
    @ApiOperation("查询计费规则操作记录列表")
    @PreAuthorize("@ss.hasPermi('system:logs:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String billingRuleCode, @RequestParam(required = false) String billingType, @RequestParam(required = false) String operationType,
                              @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false) Date operationEndTime,@RequestParam(required = false) String operator)
    {
        startPage();
        List<BillingRuleOperationLogs> list = billingRuleOperationLogsService.selectBillingRuleOperationLogsListByConditions(billingRuleCode,billingType,operationType,operationStartTime,operationEndTime,operator);
        return getDataTable(list);
    }

    /**
     * 导出计费规则操作记录列表
     */
    @ApiOperation("导出计费规则操作记录列表")
    @PreAuthorize("@ss.hasPermi('system:logs:export')")
    @Log(title = "计费规则操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String billingRuleCode, @RequestParam(required = false) String billingType, @RequestParam(required = false) String operationType,
                       @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false) Date operationEndTime,@RequestParam(required = false) String operator)
    {
        List<BillingRuleOperationLogs> list = billingRuleOperationLogsService.selectBillingRuleOperationLogsListByConditions(billingRuleCode,billingType,operationType,operationStartTime,operationEndTime,operator);
        ExcelUtil<BillingRuleOperationLogs> util = new ExcelUtil<BillingRuleOperationLogs>(BillingRuleOperationLogs.class);
        util.exportExcel(response, list, "计费规则操作记录数据");
    }

    /**
     * 通过id获取计费规则操作记录详细信息
     */
    @ApiOperation("通过id获取计费规则操作记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:logs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(billingRuleOperationLogsService.selectBillingRuleOperationLogsById(id));
    }

    /**
     * 新增计费规则操作记录
     */
    @ApiOperation("新增计费规则操作记录")
    @PreAuthorize("@ss.hasPermi('system:logs:add')")
    @Log(title = "计费规则操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BillingRuleOperationLogs billingRuleOperationLogs)
    {
        return toAjax(billingRuleOperationLogsService.insertBillingRuleOperationLogs(billingRuleOperationLogs));
    }

    /**
     * 修改计费规则操作记录
     */
    @ApiOperation("修改计费规则操作记录")
    @PreAuthorize("@ss.hasPermi('system:logs:edit')")
    @Log(title = "计费规则操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BillingRuleOperationLogs billingRuleOperationLogs)
    {
        return toAjax(billingRuleOperationLogsService.updateBillingRuleOperationLogs(billingRuleOperationLogs));
    }

    /**
     * 通过id批量删除计费规则操作记录信息
     */
    @ApiOperation("通过id批量删除计费规则操作记录信息")
    @PreAuthorize("@ss.hasPermi('system:logs:remove')")
    @Log(title = "计费规则操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(billingRuleOperationLogsService.deleteBillingRuleOperationLogsByIds(ids));
    }
}
